﻿// ----------------------------------------------------------------------------
//  Copyright (C) 成都联宇创新科技有限公司 版权所有。 
//      
//  文件名：CommonLoggingLoggerFactory.cs
//  文件功能描述：
//  创建标识：骆智慧 2016/03/04 11:41
//     
//  修改标识：骆智慧  2016/03/10/06:27
//  修改描述：
//  ----------------------------------------------------------------------------

#region 导入名称空间

using System;
using Common.Logging;
using NHibernate;

#endregion

namespace LightWork.NHibernate.CommonLogging
{
    /// <summary>
    /// <para>Implementation of the <see cref="ILoggerFactory" /> interface
    /// to allow the usage of Common.Logging 2.1 with the NHibernate
    /// logging infrastructure.</para>
    /// <para>To use this logger factory with NHibernate add the following
    /// to your App/Web.config:</para>
    /// &lt;appSettings&gt;
    /// &lt;add key="nhibernate-logger" value="NHibernate.Logging.CommonLogging.CommonLoggingLoggerFactory,
    /// NHibernate.Logging.CommonLogging"/&gt;
    /// &lt;/appSettings&gt;
    /// </summary>
    public class CommonLoggingLoggerFactory : ILoggerFactory
    {
        public IInternalLogger LoggerFor(string keyName)
        {
            return new CommonLoggingLogger(LogManager.GetLogger(keyName));
        }

        public IInternalLogger LoggerFor(Type type)
        {
            return new CommonLoggingLogger(LogManager.GetLogger(type));
        }
    }
}